package model;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 * 
 * @author Estelle && Marie
 * 
 * This class contains all elements that we need to create a formulary.
 *
 */

public class BinForm {
	
	private JTextField CallPutFlag = new JTextField("CallPutFlag");
	private JTextField S = new JTextField("S");
	private JTextField X = new JTextField("X");
	private JTextField T= new JTextField("T");
	private JTextField r=new JTextField("r");
	private JTextField b=new JTextField("b");
	private JTextField v=new JTextField("v");
	private JTextField nSteps=new JTextField("nSteps");
	private JTextField nSimulations=new JTextField("nSimulations");
	
//--------------------------------------------------------------------------------------------------------------------------------------------------------		
	
	/**
	 *  The constructor initializes each JTextField
	 */

	public BinForm(){
		Font police = new Font("Arial", Font.BOLD, 14);
		
		CallPutFlag.setFont(police);
		CallPutFlag.setPreferredSize(new Dimension(150, 30));
		CallPutFlag.setForeground(Color.magenta);
		
		S.setFont(police);
		S.setPreferredSize(new Dimension(150, 30));
		S.setForeground(Color.magenta);
		
		X.setFont(police);
		X.setPreferredSize(new Dimension(150, 30));
		X.setForeground(Color.magenta);
		
		T.setFont(police);
		T.setPreferredSize(new Dimension(150, 30));
		T.setForeground(Color.magenta);
		
		r.setFont(police);
		r.setPreferredSize(new Dimension(150, 30));
		r.setForeground(Color.magenta);
		
		b.setFont(police);
		b.setPreferredSize(new Dimension(150, 30));
		b.setForeground(Color.magenta);
		
		v.setFont(police);
		v.setPreferredSize(new Dimension(150, 30));
		v.setForeground(Color.magenta);
		
		nSteps.setFont(police);
		nSteps.setPreferredSize(new Dimension(150, 30));
		nSteps.setForeground(Color.magenta);
		
		nSimulations.setFont(police);
		nSimulations.setPreferredSize(new Dimension(150, 30));
		nSimulations.setForeground(Color.magenta);
	}
	
//--------------------------------------------------------------------------------------------------------------------------------------------------------		
	
	/**
	 * We use this function to change the text of each JTextField with the contents of a list
	 * 
	 */
	
	public void resetTextForm(BinSetVariables bin){
		
		this.CallPutFlag.setText(bin.getCallPutFlag().toString());
		this.S.setText(String.valueOf(bin.getS()));
		this.X.setText(String.valueOf(bin.getX()));
		this.T.setText(String.valueOf(bin.getT()));
		this.r.setText(String.valueOf(bin.getR()));
		this.b.setText(String.valueOf(bin.getB()));
		this.v.setText(String.valueOf(bin.getV()));
		this.nSteps.setText(String.valueOf(bin.getnSteps()));
		this.nSimulations.setText(String.valueOf(bin.getnSimulations()));
		
	}
	
//--------------------------------------------------------------------------------------------------------------------------------------------------------		
	/**
	 * we use this function to add each JTextField to a panel.
	 * we used this function in the main window at the end to add JtextField to the panel form
	 * 
	 */
	public void addToPannel(JPanel panel){
		panel.add(CallPutFlag);
		panel.add(S);
		panel.add(X);
		panel.add(T);
		panel.add(r);
		panel.add(b);
		panel.add(v);
		panel.add(nSteps);
		panel.add(nSimulations);
	}
	
//--------------------------------------------------------------------------------------------------------------------------------------------------------		
	/** 
	 * A function to check if each JTextField has been filled by the user
	 */
	
	public boolean allIsFilled(){
		
		if(this.CallPutFlag.getText().equals("CallPutFlag")) return false;
		if(this.S.getText().equals("S")) return false;
		if(this.X.getText().equals("X"))return false;
		if(this.T.getText().equals("T"))return false;
		if(this.r.getText().equals("r"))return false;
		if(this.b.getText().equals("b"))return false;
		if(this.v.getText().equals("v"))return false;
		if(this.nSteps.getText().equals("nSteps"))return false;
		if(this.nSimulations.getText().equals("nSimulations"))return false;
		
		return true;
	}
//--------------------------------------------------------------------------------------------------------------------------------------------------------		
	/**
	 * Getter and setter for each JTextField
	 * 
	 */
	public JTextField getCallPutFlag() {
		return CallPutFlag;
	}

	public void setCallPutFlag(JTextField callPutFlag) {
		CallPutFlag = callPutFlag;
	}

	public JTextField getS() {
		return S;
	}

	public void setS(JTextField s) {
		S = s;
	}

	public JTextField getX() {
		return X;
	}

	public void setX(JTextField x) {
		X = x;
	}

	public JTextField getT() {
		return T;
	}

	public void setT(JTextField t) {
		T = t;
	}

	public JTextField getR() {
		return r;
	}

	public void setR(JTextField r) {
		this.r = r;
	}

	public JTextField getB() {
		return b;
	}

	public void setB(JTextField b) {
		this.b = b;
	}

	public JTextField getV() {
		return v;
	}

	public void setV(JTextField v) {
		this.v = v;
	}

	public JTextField getnSteps() {
		return nSteps;
	}

	public void setnSteps(JTextField nSteps) {
		this.nSteps = nSteps;
	}

	public JTextField getnSimulations() {
		return nSimulations;
	}

	public void setnSimulations(JTextField nSimulations) {
		this.nSimulations = nSimulations;
	}
	
}